package com.github.baichuan.application.scaffold.rest.domain.authorization;

import com.github.baichuan.application.scaffold.rest.domain.application.Application;
import com.github.baichuan.application.scaffold.rest.domain.organization.Tenant;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Entity
@Getter
@Setter
public class Role {
    @Id
    private String id;

    @ManyToOne
    @JoinColumn(name = "application_id")
    private Application application;

    @ManyToOne
    @JoinColumn(name = "tenant_id")
    private Tenant tenant;

//    @ManyToOne
//    @JoinColumn(name = "org_uid")
//    private Org org;

    private String name;

    private String intro;

    private String code;

    @ManyToMany(cascade = CascadeType.PERSIST)
    @JoinTable(name = "role_privilege", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "resource_id"))
    private List<Resource> resources;


}
